import React, { FC } from 'react';
import { Button } from 'antd';
import { FormPanelObject } from 'lfun-bg-comp';
import BasicTop from './basicTop';
import BasicBody from './basicBody';
import Logs from './logs';

// eslint-disable-next-line react/require-default-props
const Groups: FC<{
  //title?: string;
  isEdit?: boolean;
  buttonList: React.ReactNode[];
  form?: any;
  api?: any;
}> = ({
  //title = '基本信息',
  isEdit = true,
  buttonList = [],
  form = { basicTop: {}, basicBody: {} },
  api = {},
}) => {
  //const navigate = useNavigate();
  //const params = useParams();
  const [showLogs, setShowLogs] = React.useState(false);
  const [topCntForm, setTopCntForm] = React.useState<FormPanelObject>();
  //const [topPhotoForm, setTopPhotoForm] = React.useState();

  const buildBtns = () => {
    return isEdit ? [<Button type="primary">保存</Button>] : buttonList;
  };

  return (
    <>
      <BasicTop
        onLoad={(form1: FormPanelObject) => {
          setTopCntForm(form1);
          //setTopPhotoForm(form2);
        }}
        isEdit={isEdit}
        formValue={form.basicTop}
        api={api.basicTop}
      />
      <Button
        style={{
          position: 'absolute',
          top: '415px',
          zIndex: '999',
          right: '50px',
        }}
        type="primary"
        onClick={() => setShowLogs(true)}
      >
        变更日志
      </Button>
      <Logs show={showLogs} onClose={() => setShowLogs(false)} title={topCntForm?.getFieldValue('teacher_name')} />

      <BasicBody isEdit={isEdit} buttonList={buildBtns()} formValue={form.basicBody} api={api.basicBody} />
    </>
  );
};

Groups.defaultProps = {
  //title: '基本信息',
  isEdit: true,
  form: {},
  api: {},
};

export default Groups;
